Skip to content

fix(svelte-table, vue-table): forward delete and defineProperty in live context proxy - #6684

Open
sivaraman-krishnan wants to merge 2 commits into
TanStack:mainfrom
sivaraman-krishnan:fix/6681-live-proxy-traps
Open

sivaraman-krishnan wants to merge 2 commits into
TanStack:mainfrom
sivaraman-krishnan:fix/6681-live-proxy-traps

Conversation

@sivaraman-krishnan

@sivaraman-krishnan sivaraman-krishnan commented Nov 28, 2026 •

Copy link
Copy Markdown

🎯 Changes

Fixes #6681. The issue names Svelte, but the same createLiveProxy helper was added to both the Svelte and Vue adapters in #6633, so this fixes both copies.

The proxy behind useCellContext()/useHeaderContext() had no deleteProperty or defineProperty traps. delete context.custom returned true but left the property on the cell. Object.defineProperty(context, …) wrote to the proxy's empty backing object, so later reads were stale or threw a proxy-invariant TypeError.

  • delete and Object.defineProperty are now forwarded to the current cell/header.
  • New properties are defined as configurable. The proxy reports every property as configurable because its target can change, so this keeps the reported descriptor truthful. Without it, Object.defineProperty(context, 'custom', { value }) made a non-configurable property, and a later strict-mode delete or redefinition threw. Existing properties keep their own attributes, and writable/enumerable are passed through unchanged.
  • Explicit configurable: false definitions are rejected without changing the cell, since the proxy can't keep that guarantee when the target changes.
  • Object.preventExtensions is refused for the same reason: a proxy that can switch targets can't promise a fixed key set. The backing object stays extensible.
  • Unit tests in both packages cover the issue repro, configurable new data and accessor properties, existing-key redefinition, target switching, preventExtensions, and unchanged get/set/has/ownKeys behavior.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm test and pnpm test:e2e, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

Locally I ran the unit tests, eslint, typecheck, build, publint, sherif and knip for svelte-table and vue-table (all passing); I wasn't able to run the full pnpm test / pnpm test:e2e in my environment, so I've left that box unchecked.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Live table proxies now correctly forward property deletions and definitions to the current target in Svelte and Vue.
    • Newly defined properties remain configurable, while non-configurable definitions and attempts to prevent extensions are rejected.
    • These behaviors are consistent when the proxy’s target changes.

…ve context proxy

The live proxy behind useCellContext()/useHeaderContext() (shared by the
Svelte and Vue adapters since TanStack#6633) forwarded assignment to the current
cell or header but had no deleteProperty or defineProperty traps. delete
reported success while leaving the property on the target, and
Object.defineProperty wrote to the proxy's empty backing object, so later
reads could be stale or throw a proxy-invariant TypeError.

Forward both operations to the current target, passing descriptors
through as a direct defineProperty on the cell would. Explicitly
non-configurable definitions are rejected because the proxy reports every
property as configurable and cannot keep that guarantee when the target
changes. preventExtensions is refused for the same reason, so the backing
object stays extensible and later definitions cannot mutate the target and
then fail an invariant check.

Fixes TanStack#6681

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9c8906e7-0320-4f31-b724-aba346882b96
@changeset-bot

changeset-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e6af46d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tanstack/svelte-table Patch
@tanstack/vue-table Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Svelte and Vue live proxies now forward property deletion and definition to the current target. They reject non-configurable definitions and attempts to prevent extensions. Tests cover these operations and target replacement.

Changes: Live proxy operations

Layer / File(s) Summary
Current-target proxy traps
packages/svelte-table/src/live-proxy.ts, packages/vue-table/src/live-proxy.ts
Both proxies forward property deletion and configurable property definitions to the current target. Both reject non-configurable definitions and attempts to prevent extensions.
Operation tests and release note
packages/svelte-table/tests/live-proxy.test.ts, packages/vue-table/tests/unit/live-proxy.test.ts, .changeset/live-proxy-delete-define.md
Tests cover deletion, definitions, replacement targets, extension prevention, and existing read and write behavior. The changeset declares patch releases for both packages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: kevinvandy

Merge Risk: Minimal · up to e6af4

The change makes delete and defineProperty on the Svelte and Vue live context proxies act on the current cell or header, which fixes the stale-read and TypeError behavior described in the linked issue. It is tested and scoped to an isolated helper, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two packages and the two proxy traps that were added (delete and defineProperty forwarding), which matches the main change in live-proxy.ts for both adapters. The 'fix(...)' prefix…
Description check Passed The description follows the repository template. It has a Changes section that explains the bug (missing deleteProperty and defineProperty traps), the fix (forwarding to the current target, configurab…
Linked Issues check Passed [#6681] requires that delete and defineProperty on the Svelte live context proxy act on the current cell or header, as assignment does. At head, packages/svelte-table/src/live-proxy.ts has a deletePro…
Out of Scope Changes check Passed The PR changes packages/svelte-table/src/live-proxy.ts and packages/vue-table/src/live-proxy.ts. At head, the two files contain the same createLiveProxy implementation with identical deleteProperty, d…
Full details: Title check

Explanation

The title names the two packages and the two proxy traps that were added (delete and defineProperty forwarding), which matches the main change in live-proxy.ts for both adapters. The 'fix(...)' prefix follows a conventional-commit style. The title is 85 characters, which is longer than ideal but still readable and specific.

Full details: Description check

Explanation

The description follows the repository template. It has a Changes section that explains the bug (missing deleteProperty and defineProperty traps), the fix (forwarding to the current target, configurable new properties, rejecting configurable: false, rejecting preventExtensions), and the test coverage. The checklist is filled in. The unchecked box for pnpm test and pnpm test:e2e is explained in the text, and the release-impact box is marked. Sections are complete, so the description is mostly complete.

Full details: Linked Issues check

Explanation

[#6681] requires that delete and defineProperty on the Svelte live context proxy act on the current cell or header, as assignment does. At head, packages/svelte-table/src/live-proxy.ts has a deleteProperty trap that returns Reflect.deleteProperty(getTarget(), key). It has a defineProperty trap that forwards to the current target. The trap rejects only descriptors with configurable === false. For new keys it adds configurable: true. For existing keys it passes the descriptor unchanged. The preventExtensions trap returns false, so the proxy cannot report a fixed key set while the target can change. Repro case: Object.defineProperty(context, 'custom', { value: 'new' }) applies to the current target. The later read returns 'new', and no proxy-invariant TypeError arises. Unit tests are described in the PR description. Test files were not read in this pass, so test coverage is taken from the description and not verified. Changes since the previous reviewed head could not be read as a diff because the changed blobs are unavailable. The conclusion rests on the head file contents, which match the stated behavior.

Full details: Out of Scope Changes check

Explanation

The PR changes packages/svelte-table/src/live-proxy.ts and packages/vue-table/src/live-proxy.ts. At head, the two files contain the same createLiveProxy implementation with identical deleteProperty, defineProperty, and preventExtensions traps. The PR states that #6633 added this helper to both adapters. Fixing only the Svelte copy would leave the same defect in Vue, so the Vue change supports the linked objective and is not unrelated work. The PR also adds unit tests and a changeset for both packages. These support the same change. No unrelated change was identified. The Vue extension beyond the Svelte-only issue text rests on the PR's shared-helper rationale, which the head file contents confirm. Changeset and test file contents were not read in this pass.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4f3a19e and e6af46d.

Files selected for processing: 5

  • .changeset/live-proxy-delete-define.md
  • packages/svelte-table/src/live-proxy.ts
  • packages/svelte-table/tests/live-proxy.test.ts
  • packages/vue-table/src/live-proxy.ts
  • packages/vue-table/tests/unit/live-proxy.test.ts
Files skipped from review as they are similar to previous changes: 1

  • .changeset/live-proxy-delete-define.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

…urable

Object.defineProperty(context, key, { value }) on a new key created a
non-configurable property on the cell or header (the JS default when
configurable is omitted), while the live proxy's getOwnPropertyDescriptor
reports every property as configurable. A later strict-mode delete then
threw "'deleteProperty' on proxy: trap returned falsish", and redefining
with the reported descriptor also threw.

Define new keys as configurable so the reported descriptor stays
truthful. Existing keys keep their own attributes, and explicitly
non-configurable definitions are still rejected.

Refs TanStack#6681

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9c8906e7-0320-4f31-b724-aba346882b96

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Svelte live context proxies do not forward delete or defineProperty

1 participant